char state;// construct the variable to receive chalacter 
int doorstatus = 11;// construct the variable to input 11

void setup()
{
pinMode(9,OUTPUT);// construct LED1 to pin9
pinMode(10,OUTPUT);// construct LED1 to pin10
pinMode(11,INPUT); // construct Input to pin10
Serial.begin(9600); //Configure serial

  
}
void loop()
{
 
 if(Serial.available() > 0){ // condition for Serial
  state = Serial.read(); //set the state to read the charactor
 //Serial.print(a); 


switch (state){ // set the condition with Swicth case for the charactor 
  case'U':
  if(digitalRead(doorstatus)==HIGH){ // to see if the door was close
    Serial.println("The door is Close");
  digitalWrite(9,HIGH); 
  digitalWrite(10,LOW); 
  delay(1000); 
  digitalWrite(9,LOW); 
   delay(1000); //       when press U the LED of the door look mechanism 
  digitalWrite(9,HIGH); // will be blink 1 sec twice time 
  delay(1000); 
  digitalWrite(9,LOW); 
  Serial.println("UNLOCK"); 
  }
  else if(digitalRead(doorstatus)==LOW){ // if the door is open can do notthing
  Serial.println("The door is open"); 
  }
  break;
  case'L':
  if(digitalRead(doorstatus)==HIGH){ //to see if the door was close
  Serial.println("The door is Close");
  digitalWrite(9,HIGH); //when press L the LED of the door look mechanism will be blink 1 time for 1 sec
  digitalWrite(10,HIGH); // the lamp notification is on
  delay(1000); // 
  digitalWrite(9,LOW);
  Serial.println("LOCK");
  }
  else if(digitalRead(doorstatus)==LOW){ // if the door is open can do notthing
  Serial.println("The door is open"); 
  }
  break;
    
  
}
  }
 }

 
